package cn.myzqu.sign.common.response;


import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

/**
 * 生成返回信息工具类
 * @Author: 的川
 * @Date: 2018/5/8.
 */
@NoArgsConstructor
@Data
public class ResultData  {

    private Integer code;
    private String msg;
    private Object data;

    private ResultData(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultData success(){
        return new ResultData(0,"success",null);
    }

    /**
     * 返回成功信息，带具体内容DATA
     * @param object
     * @return
     */
    public static ResultData success(Object object){
        return new ResultData(0,"success",object);
    }

    /**
     * 返回错误信息
     * @param msg
     * @return
     */
    public static ResultData error(String msg){
        return new ResultData(1,msg,null);
    }

    public static ResultData error(){
        return new ResultData(1,"fail",null);
    }

    public static ResultData error(Integer code , String msg){
        return new ResultData(code,msg,null);
    }

    public static ResultData error(Integer code , String msg,Object object){
        return new ResultData(0,"success",object);
    }


}
